﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Audio;

namespace Flight
{
    public class Sound
    {
        public static Sound loop(string sound)
        {
            return new Sound(FlightGame.game.getSound(sound));
        }


        SoundEffect soundEffect;
        SoundEffectInstance instance;

        private Sound(SoundEffect sound)
        {
            this.soundEffect = sound;
            this.instance = soundEffect.CreateInstance();

            this.instance.IsLooped = true;
            this.instance.Play();

            this.setVolume(1);
        }

        // volume = [0,1]
        public void setVolume(float volume)
        {
            this.instance.Volume = volume;
        }

        public void setFrequency(float frequency)
        {
            this.instance.Pitch = frequency;//(float)Math.Tanh(frequency);
        }
    }
}
